#!/bin/sh
# This regression test is a part of SIPp.
# [authentication username=[field0] password=[field1]] takes the nested
# keywords as its values, rather than splitting at their first ']'.
. "`dirname "$0"`/../functions"; init

printf 'SEQUENTIAL\nalice;secret;\n' >users.csv
sippfg -sf uas.xml -i 127.0.0.1 -p 25511 -m 1 -timeout 8 -timeout_error \
    >/dev/null 2>&1 &
uas=$!
sleep 1
sippfg -sf uac.xml -inf users.csv -i 127.0.0.1 -p 25510 -m 1 \
    127.0.0.1:25511 -timeout 6 -timeout_error >/dev/null 2>&1
uac_status=$?
wait $uas
uas_status=$?
rm -f users.csv

if test $uac_status -ne 0; then
    fail "UAC failed with $uac_status"
elif test $uas_status -ne 0; then
    fail "UAS failed with $uas_status: the Authorization was not alice's"
else
    ok
fi
